#ifndef _PACKET_QUEUE_H
#define _PACKET_QUEUE_H
#include "libavcodec/packet.h"
#include "libavutil/fifo.h"
#include <SDL.h>

//#include "video_state.h"
//这根本不叫list, 所以改名 由 MyAVPacketList -> MyAVPacket, 只是比AVPacket 多加了一个serial
typedef struct MyAVPacket {
    AVPacket *pkt;
    int serial; //用来判别包的连续性
} MyAVPacket;

typedef struct PacketQueue {
    AVFifoBuffer *pkt_list; //环形缓冲区,只是一个指针
    int nb_packets;
    int size;
    int64_t duration;
    int abort_request;
    int serial;
    SDL_mutex *mutex;
    SDL_cond *cond;
} PacketQueue;

int packet_queue_init(PacketQueue *q);
void packet_queue_start(PacketQueue *q);
void packet_queue_abort(PacketQueue *q);
int packet_queue_put(PacketQueue *q, AVPacket *pkt);
int packet_queue_put_nullpacket(PacketQueue *q, AVPacket *pkt, int stream_index);
int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *serial);
void packet_queue_flush(PacketQueue *q);
void packet_queue_destroy(PacketQueue *q);

#endif
